package com.jar.exercise.网络编程.UDP连接.Demo3;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/**
 * @author 松鼠
 * @date 2019/6/30 -  18:51
 */
public class Sender {
	public static void main(String[] args) {
		DatagramSocket datagramSocket = null;
		Scanner scanner = new Scanner(System.in);
		try {
			datagramSocket = new DatagramSocket();
			while (true) {
				String s = scanner.nextLine();
				DatagramPacket datagramPacket = new DatagramPacket(s.getBytes(), s.getBytes().length, InetAddress.getByName("192.168.137.1"), 8000);
				datagramSocket.send(datagramPacket);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
